home *** CD-ROM | disk | FTP | other *** search
-
- void push1(int value)
- {
- if (stack_ptr1 > stack_ptr2)
- printf("Stack 1 is full\n");
- else
- stack[stack_ptr1++] = value;
- }
-
- void push2(int value)
- {
- if (stack_ptr1 > stack_ptr2)
- printf("Stack 2 is full\n");
- else
- stack[stack_ptr2--] = value;
- }
-
- int pop1(void)
- {
- if (stack_ptr1 == 0) {
- printf("Stack 1 is empty\n");
- return 0;
- }
-
- return stack[--stack_ptr1];
- }
-
- int pop2(void)
- {
- if (stack_ptr2 == STACK_SIZE - 1) {
- printf("Stack 2 is empty\n");
- return 0;
- }
-
- return stack[++stack_ptr2];
- }
-
- void dump_stack(void)
- {
- int i;
-
- printf("Stack contains: ");
- for (i = 0; i < STACK_SIZE; ++i)
- printf("%4d", stack[i]);
-
- printf("\tsp1 = %lu, sp2 = %lu\n",
- (unsigned long)stack_ptr1, (unsigned long)stack_ptr2);
- }
-
-